package com.rui.study.micro.userself.model;

import lombok.Getter;

/**
 * @program: study
 * @description:
 * @author: Yaowr
 * @create: 2018-11-15 14:44
 **/
@Getter
public enum RegistWay {
    PHONE(0, "手机"),
    EMAIL(1, "邮箱");

    private int code;
    private String desc;

    RegistWay(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static RegistWay parse(String s) {
        for (RegistWay registWay : RegistWay.values()) {
            if (registWay.code == Integer.valueOf(s)
                    || registWay.name().equalsIgnoreCase(s)
                    || registWay.getDesc().equals(s)) {
                return registWay;
            }
        }
        return null;
    }
}
